/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package wordcount;

import java.util.List;
import java.util.Map;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		System.out.println("查询单词的长度");
		int num=sc.nextInt();
		FileRead fileRead = new FileRead();
		WordCount count = fileRead.readTxtFile("test\\classes\\1.txt");
		if (count == null) {
			System.out.println("文件里的数据为空");
		} else {
			List<Map.Entry<String, String>> list = count.sortMap();
			System.out.println("characters:" + count.getCharacters());
			System.out.println("words:" + count.getWords());
			System.out.println("lines:" + count.getLines());
			if (list.size() < 10) {
				for (int i = 0; i < list.size(); i++) {
					if (list.get(i).getKey().length() == num) {
						System.out.println("<" + list.get(i).getKey() + ">:" + list.get(i).getValue());
					}
				}
			} else {
				for (int i = 0; i < 10; i++) {
					if (list.get(i).getKey().length() == num) {
						System.out.println("<" + list.get(i).getKey() + ">:" + list.get(i).getValue());
					}
				}
			}

		}
		System.out.println(args);
	}
}
